package com.dxtan90.util;

import com.dxtan90.bean.RGB;

public class RGBUtil {

    public static int RGBToColor(int alpha, int red, int green, int blue) {
        int newPixel = 0;
        newPixel += alpha;
        newPixel = newPixel << 8;
        newPixel += red;
        newPixel = newPixel << 8;
        newPixel += green;
        newPixel = newPixel << 8;
        newPixel += blue;
        return newPixel;
    }
    public static int RGBToColor(RGB rgb){
        return RGBToColor(0,rgb.r,rgb.g,rgb.b);
    }

    public static RGB ColorToRGB(int color){
        RGB rgb = new RGB();
        rgb.r = (color >> 16) & 0xff;
        rgb.g = (color >> 8) & 0xff;
        rgb.b = color & 0xff;
        return rgb;
    }
}
